<?php
	include_once "db_connect.php";

	//====================================================
	// 후기 리스트 가져오기
	//====================================================
	
	// 쿼리문 작성
	$sql  = " SELECT ";
	$sql .= "       B.idx ";
	$sql .= "     , B.category ";
	$sql .= "     , B.user_id ";
	$sql .= "     , B.nickname ";
	$sql .= "     , B.service_id ";
	$sql .= "     , S.service_url ";
	$sql .= "     , S.service_name ";
	$sql .= "     , (SELECT service_group_name FROM tb_service_group WHERE service_group_id = S.service_group_id) service_group_name ";
	$sql .= "     , B.subject ";
	$sql .= "     , B.content ";
	$sql .= "     , B.recommend ";
	$sql .= "     , B.hit ";
	$sql .= " FROM  tb_bbs B ";
	$sql .= " JOIN  tb_service S ON B.service_id = S.service_id ";
	$sql .= " WHERE 1=1 ";
	$sql .= " AND   category = 'postscript' ";
	$sql .= " AND   B.notice_yn = 'N' ";
	$sql .= " ORDER BY B.create_dt DESC ";
	$sql .= " LIMIT 0, 3 ";
	
	$postscript_list = query_to_array($sql);
	
	// 썸네일 이미지 파일명
	$ps_thumb = array(
		  'star_todaybirth' => 'sum_star_86.jpg'
		, 'star_gunghap'    => 'sum_star_86.jpg'
		, 'money_mymoney'   => 'sum_money_86.jpg'
		, 'money_gunghap'   => 'sum_money_86.jpg'
		, 'saju_total'      => 'sum_saju_86.jpg'
		, 'tojung_total'    => 'sum_tog_86.jpg'
		, 'gunghap_mylover' => 'sum_gh_86.jpg'
		, 'gunghap_sintong' => 'sum_gh_86.jpg'
		, 'gunghap_style'   => 'sum_gh_86.jpg'
		, 'adult_total'     => 'sum_sex_86.jpg'
		, 'free_today'      => 'sum_today_86.jpg'
		, 'theme_business'    => 'sum_theme_86.jpg'
		, 'theme_joint'       => 'sum_theme_86.jpg'
		, 'theme_children'    => 'sum_theme_86.jpg'
		, 'theme_savemoney'   => 'sum_theme_86.jpg'
		, 'theme_defendmoney' => 'sum_theme_86.jpg'
		, 'theme_moneytech'   => 'sum_theme_86.jpg'
		, 'theme_subordinate' => 'sum_theme_86.jpg'
		, 'theme_boss'        => 'sum_theme_86.jpg'
	);
?>
			<div class="sub_board">
				<h3><img src="/images/main/tit_board.gif" /></h3>
				<ul class="review">
					<li>
						<a href="/bbs/postscript/read?idx=<?=$postscript_list[0]['idx']?>"class="img"><img src="/images/common/sum/<?=$ps_thumb[$postscript_list[0]['service_id']]?>" align="absmiddle"  /></a>
						<span class="txt1">[<?=substr($postscript_list[0]['service_id'],0,4)=='free' ? '무료운세' : $postscript_list[0]['service_name']?>]<span class="title"><?=mb_strlen($postscript_list[0]['subject'], 'utf-8') > 18 ? mb_substr($postscript_list[0]['subject'], 0, 18, 'utf-8').'..' : $postscript_list[0]['subject']?></span><span>│ <?=$postscript_list[0]['nickname']?></span><em><img src="/images/common/board/icon_heart.png" alt="베스트공감" /><?=$postscript_list[0]['recommend']?></em></span>
						<span class="txt2"><a href="/bbs/postscript/read?idx=<?=$postscript_list[0]['idx']?>"><?=mb_strlen($postscript_list[0]['content'], 'utf-8') > 70 ? mb_substr($postscript_list[0]['content'], 0, 70, 'utf-8').'..' : $postscript_list[0]['content']?></a></span>
						<!--<span class="txt3"><a href="#">자세히보러가기<img src="/images/common/bul_arrow.gif" alt="자세히보러가기" /></a></span>-->
					</li>
<?
	$cnt = count($postscript_list);
	for ($i=1; $i < $cnt; $i++) {
		$item = $postscript_list[$i];
?>
					<li class="list <?=$i == $cnt-1 ? 'end' : ''?>">
						<span class="txt1">[<?=substr($postscript_list[$i]['service_id'],0,4)=='free' ? '무료운세' : $postscript_list[$i]['service_name']?>]<span class="title"><?=mb_strlen($item['subject'], 'utf-8') > 39 ? mb_substr($item['subject'], 0, 39, 'utf-8').'..' : $item['subject']?> </span><span>│ <?=$postscript_list[$i]['nickname']?></span><em><img src="/images/common/board/icon_heart2.png" alt="공감" /><?=$postscript_list[$i]['recommend']?></em></span>
						<span class="txt2"><a href="/bbs/postscript/read?idx=<?=$item['idx']?>"><?=mb_strlen($item['content'], 'utf-8') > 45 ? mb_substr($item['content'], 0, 45, 'utf-8').'..' : $item['content']?></a></span>
						<!--<span class="txt3"><a href="#">자세히보러가기<img src="/images/common/bul_arrow.gif" alt="자세히보러가기" /></a></span>-->
						
					</li>
<?	} ?>
				</ul>
			</div>